package com.panda.web.utils.task;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.panda.web.domain.vo.JobVO;
import com.panda.web.entity.wechat.WechatUser;
import com.panda.web.entity.wechatinfo.WechatUserinfo;
import com.panda.web.mapper.wechat.WechatUserMapper;
import com.panda.web.mapper.wechatinfo.WechatUserinfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class UserInfoTask {

    @Autowired
    WechatUserMapper userMapper;
    @Autowired
    WechatUserinfoMapper userinfoMapper;

    @Async
//    @Scheduled(cron = "*/10 * * * * ?")//10秒执行一次
    @Scheduled(cron = "0 0 0 * * ?")
    public void dailyTask() {
        List<WechatUserinfo> userinfoList = userinfoMapper.findBySelectList();
        if (userinfoList != null && !userinfoList.isEmpty()) {
            for (WechatUserinfo userinfo : userinfoList) {
                userinfo.setScreenNumber(20);
                userinfoMapper.updateById(userinfo);
            }
        }

        //测试单账号
        // WechatUserinfo userinfo1 = userinfoMapper.findByOpenid("o9Zsy5wA0mDTND183FGdT9cEmJcU");
//        userinfo1.setScreenNumber(20);
//        userinfoMapper.updateById(userinfo1);

    }

}
